package t25524;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Delete {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Connection connection = SqlConnection.getConnection();
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入用户id");
        int  id = scanner.nextInt();

        String sql = "DELETE FROM users WHERE id = ?";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1,id);

        int i  = preparedStatement.executeUpdate();
        if (i<=0) {
            System.out.println("删除成功");
        } else {
            System.out.println("删除失败");
        }

    }
}
